<?php

use yii\helpers\Html;
use kartik\dynagrid\DynaGrid;
use yii\helpers\Url;
use kartik\grid\GridView;
use yii\helpers\ArrayHelper;
use common\models\Depot;

/* @var $this yii\web\View */
/* @var $searchModel common\models\GoodsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '采购管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<?php $this->beginBlock('content-header') ?>
<?= $this->title  ?>
<?php $this->endBlock() ?>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <div class="box box-primary">
        <div class="box-body">
        <?=
        DynaGrid::widget([
            'columns'=>[
                'id',
                'name',
                'sn',
                'format',
                'num',
                'unit',
                'price',
                [
                    'attribute'=>'created_at',
                    'filterType' => GridView::FILTER_DATE,
                    'filterWidgetOptions' => [
                        'pluginOptions' => [
                            'allowClear' => true,
                            'format' => 'yyyy-mm-dd',
                            'todayHighlight' => true
                        ],
                    ],
                    'filterInputOptions' => ['placeholder' => '请选择'],
                ],
                [
                 'attribute'=>"admin_id", 
                 'label'=>'录入人',
                 'value'=>'admin.username'
                ],
                [
                    'attribute'=>"depot_id",
                    'label'=>'所在仓库',
                    'value'=>'depot.name',
                    'filterType' =>GridView::FILTER_SELECT2,
                    'filter' =>ArrayHelper::map(Depot::find()->all(),'id','name'),
                    'filterWidgetOptions' => [
                        'pluginOptions' => ['allowClear' => true],
                    ],
                    'filterInputOptions' => ['placeholder' => '请选择'],
                ],
                [
                    'attribute'=>"position_name",
                    'label'=>'所在仓位',
                    'value'=>'position.sn',
//                     'filterType' => GridView::FILTER_TYPEAHEAD,
//                     'filterInputOptions' => ['placeholder' => '请选择'],
                    
                ],
                ['class' => 'kartik\grid\ActionColumn','template'=>'{update}','dropdown'=>true,'dropdownButton'=>['label'=>'工具箱','class'=>'btn btn-default'],  'dropdownOptions' => ['class' => 'float-right'],'headerOptions' => ['class' => 'kartik-sheet-style']],
            ],
            'storage'=>DynaGrid::TYPE_COOKIE,
            'theme'=>'panel-danger',
            'gridOptions'=>[
                'dataProvider'=>$dataProvider,
                'filterModel'=>$searchModel,
                'panel'=>[
                    'heading'=>false,
                    'type'=>'success',
                    'before'=>Html::a('<i class="glyphicon glyphicon-plus"></i>录入物品', ['create'], ['class' => 'btn btn-success']),
                ],
            ],
            'options'=>['id'=>'dynagrid-1'] // a unique identifier is important
        ]);
        ?>
        
        
        
        </div>
    </div>
